package com.lft.josephu;

/**
 * Function: 		ADD FUNCTION.
 * Reason:   		ADD REASON.
 * Date:            2020-10-10 21:46
 * <p>
 * Class Name:      JosephuDemo
 * Package Name:    com.lft.josephu
 * @author Laifengting / E-mail:laifengting@foxmail.com
 * @version 1.0.0
 * @since JDK 8
 */
public class JosephuDemo {
	public static void main(String[] args) {
		System.out.println("创建约瑟夫环——遍历");
		Boy first = JosephuUtil.create(5);
		JosephuUtil.list(first);
		
		System.out.println();
		System.out.println("添加节点——遍历");
		first = JosephuUtil.add(first, new Boy(6));
		JosephuUtil.list(first);
		
		System.out.println();
		System.out.println("按编号添加节点——遍历");
		Boy newFirst = JosephuUtil.addByOrder(first, new Boy(7));
		JosephuUtil.list(newFirst);
		
		System.out.println();
		System.out.println("删除节点——遍历");
		newFirst = JosephuUtil.delete(newFirst, new Boy(6));
		JosephuUtil.list(newFirst);
		
		System.out.println();
		System.out.println("报数取出节点");
		JosephuUtil.countBoys(newFirst, 1, 2);
	}
}